﻿using DynamicDNS.Wcf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;

namespace DynamicDNS.Console
{
    class Program
    {
        private static ConfigurationService updater = ConfigurationService.Instance;
        internal static ServiceHost ConfigurationServiceHost = null;
        static void Main(string[] args)
        {
            if (ConfigurationServiceHost != null)
                ConfigurationServiceHost.Close();
            ConfigurationServiceHost = new ServiceHost(updater);
            var behavior = ConfigurationServiceHost.Description.Behaviors.Find<ServiceBehaviorAttribute>();
            behavior.InstanceContextMode = InstanceContextMode.Single;
            ConfigurationServiceHost.Open();

            var record = new Model.Record() { Domain = "sathai.com", Host = "test", Password = "uchxttkl", Interval = Model.UpdateInterval.m1 };
            
            int i = 0;
            while (true)
            {
                System.Console.Write(i++);
                updater.UpdateAll(true);
                System.Threading.Thread.Sleep(1000);
            }
        }
    }
}
